*Do-File for honours thesis: "Learning from Stories: A New Analysis of New Zealand Monetary Policy Shocks" by Jonathan Reddell*

*---------------------------------------------------*
*Baseline Local Projection Results 
*Only coefficients, not graphs, those assembled in Excel*
*---------------------------------------------------*
log using ThesisReplicationFile

*Part 1 - Contractionary (including partial shocks)*
use "C:\Users\jonat\OneDrive\Documents\Thesis Stuff\Thesis data -  Stata - Contractionary (including partial shocks).dta"


*Doing LP - Baseline specification*
tsset time

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(ShockMe L(1/4).ShockMe) dfk small vce(hac nwest) level(90)
	test [ShockMe]`var' [ShockMe]F1.`var' [ShockMe]F2.`var' [ShockMe]F3.`var' [ShockMe]F4.`var' [ShockMe]F5.`var' [ShockMe]F6.`var' [ShockMe]F7.`var' [ShockMe]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(ShockMe L(1/4).ShockMe) dfk small vce(hac nwest) level(90)
	test [ShockMe]`var' [ShockMe]F1.`var' [ShockMe]F2.`var' [ShockMe]F3.`var' [ShockMe]F4.`var' [ShockMe]F5.`var' [ShockMe]F6.`var' [ShockMe]F7.`var'
}

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small vce(hac nwest) level(90)
	test [Shock4oM]`var' [Shock4oM]F1.`var' [Shock4oM]F2.`var' [Shock4oM]F3.`var' [Shock4oM]F4.`var' [Shock4oM]F5.`var' [Shock4oM]F6.`var' [Shock4oM]F7.`var' [Shock4oM]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small vce(hac nwest) level(90)
	test [Shock4oM]`var' [Shock4oM]F1.`var' [Shock4oM]F2.`var' [Shock4oM]F3.`var' [Shock4oM]F4.`var' [Shock4oM]F5.`var' [Shock4oM]F6.`var' [Shock4oM]F7.`var' 
}

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
	test [Shock4o]`var' [Shock4o]F1.`var' [Shock4o]F2.`var' [Shock4o]F3.`var' [Shock4o]F4.`var' [Shock4o]F5.`var' [Shock4o]F6.`var' [Shock4o]F7.`var' [Shock4o]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
	test [Shock4o]`var' [Shock4o]F1.`var' [Shock4o]F2.`var' [Shock4o]F3.`var' [Shock4o]F4.`var' [Shock4o]F5.`var' [Shock4o]F6.`var' [Shock4o]F7.`var'
}


*Part 2: Contractionary (Excluding partial shocks)*
use "C:\Users\jonat\OneDrive\Documents\Thesis Stuff\Thesis data - Stata - Contractionary (excluding partial shocks).dta"

*Doing LP*
tsset time

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(ShockMe L(1/4).ShockMe) dfk small vce(hac nwest) level(90)
	test [ShockMe]`var' [ShockMe]F1.`var' [ShockMe]F2.`var' [ShockMe]F3.`var' [ShockMe]F4.`var' [ShockMe]F5.`var' [ShockMe]F6.`var' [ShockMe]F7.`var' [ShockMe]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(ShockMe L(1/4).ShockMe) dfk small vce(hac nwest) level(90)
	test [ShockMe]`var' [ShockMe]F1.`var' [ShockMe]F2.`var' [ShockMe]F3.`var' [ShockMe]F4.`var' [ShockMe]F5.`var' [ShockMe]F6.`var' [ShockMe]F7.`var'
}

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small vce(hac nwest) level(90)
	test [Shock4oM]`var' [Shock4oM]F1.`var' [Shock4oM]F2.`var' [Shock4oM]F3.`var' [Shock4oM]F4.`var' [Shock4oM]F5.`var' [Shock4oM]F6.`var' [Shock4oM]F7.`var' [Shock4oM]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small vce(hac nwest) level(90)
	test [Shock4oM]`var' [Shock4oM]F1.`var' [Shock4oM]F2.`var' [Shock4oM]F3.`var' [Shock4oM]F4.`var' [Shock4oM]F5.`var' [Shock4oM]F6.`var' [Shock4oM]F7.`var' 
}

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
	test [Shock4o]`var' [Shock4o]F1.`var' [Shock4o]F2.`var' [Shock4o]F3.`var' [Shock4o]F4.`var' [Shock4o]F5.`var' [Shock4o]F6.`var' [Shock4o]F7.`var' [Shock4o]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
	test [Shock4o]`var' [Shock4o]F1.`var' [Shock4o]F2.`var' [Shock4o]F3.`var' [Shock4o]F4.`var' [Shock4o]F5.`var' [Shock4o]F6.`var' [Shock4o]F7.`var'
}



*Part 3: Expansionary (All shocks partial)*
use "C:\Users\jonat\OneDrive\Documents\Thesis Stuff\Thesis data - Stata - Expansionary shocks.dta"
*Doing LP*
tsset time

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small vce(hac nwest) level(90)
	test [Shock4oM]`var' [Shock4oM]F1.`var' [Shock4oM]F2.`var' [Shock4oM]F3.`var' [Shock4oM]F4.`var' [Shock4oM]F5.`var' [Shock4oM]F6.`var' [Shock4oM]F7.`var' [Shock4oM]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small vce(hac nwest) level(90)
	test [Shock4oM]`var' [Shock4oM]F1.`var' [Shock4oM]F2.`var' [Shock4oM]F3.`var' [Shock4oM]F4.`var' [Shock4oM]F5.`var' [Shock4oM]F6.`var' [Shock4oM]F7.`var' 
}

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
	test [Shock4o]`var' [Shock4o]F1.`var' [Shock4o]F2.`var' [Shock4o]F3.`var' [Shock4o]F4.`var' [Shock4o]F5.`var' [Shock4o]F6.`var' [Shock4o]F7.`var' [Shock4o]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
	test [Shock4o]`var' [Shock4o]F1.`var' [Shock4o]F2.`var' [Shock4o]F3.`var' [Shock4o]F4.`var' [Shock4o]F5.`var' [Shock4o]F6.`var' [Shock4o]F7.`var'
}

*------------------------------------------------*
*Robustness Checks*
*------------------------------------------------*
*Part 1 - Comparing standard errors, just with baseline shock series*
use "C:\Users\jonat\OneDrive\Documents\Thesis Stuff\Thesis data -  Stata - Contractionary (including partial shocks).dta"
tsset time

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(ShockMe L(1/4).ShockMe) dfk small level(90)
	test [ShockMe]`var' [ShockMe]F1.`var' [ShockMe]F2.`var' [ShockMe]F3.`var' [ShockMe]F4.`var' [ShockMe]F5.`var' [ShockMe]F6.`var' [ShockMe]F7.`var' [ShockMe]F8.`var'
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(ShockMe L(1/4).ShockMe) dfk small level(90)
}

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small level(90)
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4oM L(1/4).Shock4oM) dfk small level(90)
}

foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small level(90)
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small level(90)
}

*----------------------------------------*
*Instrumental variable specification*
*----------------------------------------*
tsset time
gen dOCR = OCR - l.OCR
*Part 1 - Narrative shock series*
local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnGDP_`h' = f`h'.lnGDP - l.lnGDP
    ivregress 2sls lnGDP_`h' (dOCR = ShockMe) ///
        l(1/4).lnGDP l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage


local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnResidentialInvestment_`h' = f`h'.lnResidentialInvestment - l.lnResidentialInvestment
    ivregress 2sls lnResidentialInvestment_`h' (dOCR = ShockMe) ///
        l(1/4).lnResidentialInvestment l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen CAB_`h' = f`h'.CAB - l.CAB
    ivregress 2sls CAB_`h' (dOCR = ShockMe) ///
        l(1/4).CAB l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen TradeBalance_`h' = f`h'.TradeBalance - l.TradeBalance
    ivregress 2sls TradeBalance_`h' (dOCR = ShockMe) ///
        l(1/4).TradeBalance l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen UnemploymentRate_`h' = f`h'.UnemploymentRate - l.UnemploymentRate
    ivregress 2sls UnemploymentRate_`h' (dOCR = ShockMe) ///
        l(1/4).UnemploymentRate l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen lnConsumption_`h' = f`h'.lnConsumption - l.lnConsumption
    ivregress 2sls lnConsumption_`h' (dOCR = ShockMe) ///
        l(1/4).lnConsumption l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationLFE_`h' = f`h'.InflationLFE - l.InflationLFE
    ivregress 2sls InflationLFE_`h' (dOCR = ShockMe) ///
        l(1/4).InflationLFE l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationSFM_`h' = f`h'.InflationSFM - l.InflationSFM
    ivregress 2sls InflationSFM_`h' (dOCR = ShockMe) ///
        l(1/4).InflationSFM l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

*Part 2 - GPT4o Shock series*
local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnGDP_`h' = f`h'.lnGDP - l.lnGDP
    ivregress 2sls lnGDP_`h' (dOCR = Shock4o) ///
        l(1/4).lnGDP l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
	
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnResidentialInvestment_`h' = f`h'.lnResidentialInvestment - l.lnResidentialInvestment
    ivregress 2sls lnResidentialInvestment_`h' (dOCR = Shock4o) ///
        l(1/4).lnResidentialInvestment l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen CAB_`h' = f`h'.CAB - l.CAB
    ivregress 2sls CAB_`h' (dOCR = Shock4o) ///
        l(1/4).CAB l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen TradeBalance_`h' = f`h'.TradeBalance - l.TradeBalance
    ivregress 2sls TradeBalance_`h' (dOCR = Shock4o) ///
        l(1/4).TradeBalance l(1/4).dOCR, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen UnemploymentRate_`h' = f`h'.UnemploymentRate - l.UnemploymentRate
    ivregress 2sls UnemploymentRate_`h' (dOCR = Shock4o) ///
        l(1/4).UnemploymentRate l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen lnConsumption_`h' = f`h'.lnConsumption - l.lnConsumption
    ivregress 2sls lnConsumption_`h' (dOCR = Shock4o) ///
        l(1/4).lnConsumption l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationLFE_`h' = f`h'.InflationLFE - l.InflationLFE
    ivregress 2sls InflationLFE_`h' (dOCR = Shock4o) ///
        l(1/4).InflationLFE l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationSFM_`h' = f`h'.InflationSFM - l.InflationSFM
    ivregress 2sls InflationSFM_`h' (dOCR = Shock4o) ///
        l(1/4).InflationSFM l(1/4).dOCR, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

*Controlling for GFC Impacts*
gen dummy_2008q4 = (time==tq(2008q4))
gen dummy_2009q1 = (time==tq(2009q1))
local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnGDP_`h' = f`h'.lnGDP - l.lnGDP
    ivregress 2sls lnGDP_`h' (dOCR = ShockMe) ///
        l(1/4).lnGDP l(1/4).dOCR dummy_2008q4 dummy_2009q1, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen UnemploymentRate_`h' = f`h'.UnemploymentRate - l.UnemploymentRate
    ivregress 2sls UnemploymentRate_`h' (dOCR = ShockMe) ///
        l(1/4).UnemploymentRate l(1/4).dOCR dummy_2008q4 dummy_2009q1, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationLFE_`h' = f`h'.InflationLFE - l.InflationLFE
    ivregress 2sls InflationLFE_`h' (dOCR = ShockMe) ///
        l(1/4).InflationLFE l(1/4).dOCR dummy_2008q4 dummy_2009q1, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

*Controlling for trading partner GDP*
local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnGDP_`h' = f`h'.lnGDP - l.lnGDP
    ivregress 2sls lnGDP_`h' (dOCR = ShockMe) ///
        l(1/4).lnGDP l(1/4).dOCR l(1/4).LnTPGDP, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen UnemploymentRate_`h' = f`h'.UnemploymentRate - l.UnemploymentRate
    ivregress 2sls UnemploymentRate_`h' (dOCR = ShockMe) ///
        l(1/4).UnemploymentRate l(1/4).dOCR l(1/4).TPGDPgrowth, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationLFE_`h' = f`h'.InflationLFE - l.InflationLFE
    ivregress 2sls InflationLFE_`h' (dOCR = ShockMe) ///
        l(1/4).InflationLFE l(1/4).dOCR l(1/4).TPGDPgrowth, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnGDP_`h' = f`h'.lnGDP - l.lnGDP
    ivregress 2sls lnGDP_`h' (dOCR = ShockMe) ///
        l(1/4).lnGDP l(1/4).dOCR l(1/4).TPGDPgrowth, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen UnemploymentRate_`h' = f`h'.UnemploymentRate - l.UnemploymentRate
    ivregress 2sls UnemploymentRate_`h' (dOCR = ShockMe) ///
        l(1/4).UnemploymentRate l(1/4).dOCR l(1/4).LnTPGDP, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationLFE_`h' = f`h'.InflationLFE - l.InflationLFE
    ivregress 2sls InflationLFE_`h' (dOCR = ShockMe) ///
        l(1/4).InflationLFE l(1/4).dOCR l(1/4).LnTPGDP, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

*Checking other economic activity indicators - TP gdp control*
local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnResidentialInvestment_`h' = f`h'.lnResidentialInvestment - l.lnResidentialInvestment
    ivregress 2sls lnResidentialInvestment_`h' (dOCR = ShockMe) ///
        l(1/4).lnResidentialInvestment l(1/4).dOCR l(1/4).LnTPGDP, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen lnConsumption_`h' = f`h'.lnConsumption - l.lnConsumption
    ivregress 2sls lnConsumption_`h' (dOCR = ShockMe) ///
        l(1/4).lnConsumption l(1/4).dOCR l(1/4).LnTPGDP, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage


*Taylor rule style control test - controlling for lags of GDP and InflationLFE*
local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnGDP_`h' = f`h'.lnGDP - l.lnGDP
    ivregress 2sls lnGDP_`h' (dOCR = ShockMe) ///
        l(1/4).lnGDP l(1/4).dOCR l(1/4).lnInflationLFE_Index, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnResidentialInvestment_`h' = f`h'.lnResidentialInvestment - l.lnResidentialInvestment
    ivregress 2sls lnResidentialInvestment_`h' (dOCR = ShockMe) ///
        l(1/4).lnResidentialInvestment l(1/4).dOCR l(1/4).lnInflationLFE_Index l(1/4).lnGDP, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen CAB_`h' = f`h'.CAB - l.CAB
    ivregress 2sls CAB_`h' (dOCR = ShockMe) ///
        l(1/4).CAB l(1/4).dOCR l(1/4).lnInflationLFE_Index l(1/4).lnGDP, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 7
forvalues h = 0/`horizon' {
    cap gen TradeBalance_`h' = f`h'.TradeBalance - l.TradeBalance
    ivregress 2sls TradeBalance_`h' (dOCR = ShockMe) ///
        l(1/4).TradeBalance l(1/4).dOCR l(1/4).lnInflationLFE_Index l(1/4).lnGDP, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen UnemploymentRate_`h' = f`h'.UnemploymentRate - l.UnemploymentRate
    ivregress 2sls UnemploymentRate_`h' (dOCR = ShockMe) ///
        l(1/4).UnemploymentRate l(1/4).dOCR l(1/4).InflationLFE l(1/4).GDP_growthrate, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen lnConsumption_`h' = f`h'.lnConsumption - l.lnConsumption
    ivregress 2sls lnConsumption_`h' (dOCR = ShockMe) ///
        l(1/4).lnConsumption l(1/4).dOCR l(1/4).InflationLFE l(1/4).GDP_growthrate, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationLFE_`h' = f`h'.InflationLFE - l.InflationLFE
    ivregress 2sls InflationLFE_`h' (dOCR = ShockMe) ///
        l(1/4).InflationLFE l(1/4).dOCR l(1/4).GDP_growthrate, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage

local horizon = 8
forvalues h = 0/`horizon' {
    cap gen InflationSFM_`h' = f`h'.InflationSFM - l.InflationSFM
    ivregress 2sls InflationSFM_`h' (dOCR = ShockMe) ///
        l(1/4).InflationSFM l(1/4).dOCR l(1/4).InflationLFE l(1/4).GDP_growthrate, small vce(hac bartlett 8) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7 horizon_8, stats(b se t p)
estat firststage


*SHOCK DECOMPOSITION*
*Comparing shared vs not shared ChatGPT shocks*
*Not shared*
replace Shock4o = 0 in 36
replace Shock4o = 0 in 41
replace Shock4o = 0 in 100
foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
}

*Shared*
replace Shock4o = 1 in 36
replace Shock4o = 1 in 41
replace Shock4o = 1 in 100
replace Shock4o = 0 in 69
replace Shock4o = 0 in 72
replace Shock4o = 0 in 29
replace Shock4o = 0 in 14
replace Shock4o = 0 in 21


foreach var in UnemploymentRate InflationSFM InflationLFE lnConsumption {
	lpirf `var', step(9) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
}

foreach var in lnGDP lnResidentialInvestment CAB TradeBalance {
	lpirf `var', step(8) lags (1/4) exog(Shock4o L(1/4).Shock4o) dfk small vce(hac nwest) level(90)
}

log close 
translate ThesisReplicationFile.smcl ThesisReplicationFile.pdf 

/*Final Robustness Check: Had to be seperate for stata in memory reasons* Checking effect on GDP when excluding partial shocks - TP GDP control*
use "C:\Users\jonat\OneDrive\Documents\Thesis Stuff\Thesis data - Stata - Contractionary (excluding partial shocks).dta"
tsset time
gen dOCR = OCR - l.OCR
local horizon = 7
forvalues h = 0/`horizon' {
    cap gen lnGDP_`h' = f`h'.lnGDP - l.lnGDP
    ivregress 2sls lnGDP_`h' (dOCR = ShockMe) ///
        l(1/4).lnGDP l(1/4).dOCR l(1/4).LnTPGDP, small vce(hac bartlett 7) level(90)
    estimates store horizon_`h'
}
estimates table horizon_0 horizon_1 horizon_2 horizon_3 horizon_4 horizon_5 horizon_6 horizon_7, stats(b se t p)
estat firststage
